package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.base.util.JwtUtils;
import com.atguigu.srb.core.pojo.entity.BorrowInfo;
import com.atguigu.srb.core.pojo.vo.BorrowInfoApprovalVO;
import com.atguigu.srb.core.pojo.vo.BorrowerDetailVO;
import com.atguigu.srb.core.service.BorrowInfoService;
import com.atguigu.srb.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author fun
 * @since 2021-10-29
 */
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowInfoController {
    @Autowired
    BorrowInfoService borrowInfoService;

    @GetMapping("/list")
    public R list() {
            List<BorrowInfo> borrowInfoList = borrowInfoService.getBorrowInfoList();
            return R.ok().data("list", borrowInfoList);
    }

    @GetMapping("/show/{id}")
    public R show(@PathVariable("id") Long id) {
        Map<String,Object> map = borrowInfoService.getBorrowInfoDetail(id);
        return R.ok().data("borrowInfoDetail", map);
    }

    @PostMapping("/approval")
    public R approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO) {
        borrowInfoService.approval(borrowInfoApprovalVO);
        return R.ok();
    }
}

